﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication.Code;
using Telerik.Web.UI;

namespace WebApplication.Controls.Management.Company
{
	public partial class LocationEditControl : UserControl
	{
		protected void Page_Init(object sender, EventArgs e)
		{
			//ConfigureWindows();
			//GridEditableItem item = this.Parent.NamingContainer as GridEditableItem;
			//if (item == null || item.DataItem == null)
			//{
			//    return;
			//}

			//if (item.DataItem is GridInsertionObject)
			//{
			//    btUpdate.Visible = false;
			//    return;
			//}

			//btInsert.Visible = false;
			//int locationId = int.Parse(item["Id"].Text);
			//DistrictTextBox.Text = item["District"].Text;
			//StreetTextBox.Text = item["Street"].Text;
			//BuildingNumberTextBox.Text = item["BuildingNumber"].Text;
			//LocalNumberTextBox.Text = item["LocalNumber"].Text;
			//CityIdTextBox.Text = item["CityId"].Text;
			//CityNameTextBox.Text = item["CityName"].Text;
			//ProvinceNameTextBox.Text = item["ProvinceName"].Text;
			return;
		}

		//public DTOAddress EditedAddress
		//{
		//    get
		//    {
		//        DTOAddress dtoAddress = new DTOAddress()
		//        {
		//            Disctrict = DistrictTextBox.Text,
		//            Street = StreetTextBox.Text,
		//            BuildingNumber = BuildingNumberTextBox.Text,
		//            LocalNumber = LocalNumberTextBox.Text
		//        };

		//        if (string.IsNullOrEmpty(CityIdTextBox.Text))
		//        {
		//            return dtoAddress;
		//        }

		//        dtoAddress.City = new DTOCity()
		//        {
		//            Id = int.Parse(CityIdTextBox.Text),
		//            Name = CityNameTextBox.Text
		//        };

		//        return dtoAddress;
		//    }
		//}

		private void ConfigureWindows()
		{
			ConfigureSelectCityForm();
			ConfigureSelectChainStoreForm();
		}

		private void ConfigureSelectCityForm()
		{
//            SelectCityWindow.OpenerElementID = SelectCity.ClientID;
//            SelectCityWindow.OnClientClose = @"
//            function(sender, args)
//            {
//				var city = args.get_argument();
//				if (city) {
//					$get('" + AddressCity.ClientID + @"').value = city.Name;
//					$get('" + AddressProvince.ClientID + @"').value = city.Province.Name;
//				}
//            }
//            ";
		}

		private void ConfigureSelectChainStoreForm()
		{
//            SelectChainStoreWindow.OpenerElementID = SelectChainStoreButton.ClientID;
//            SelectChainStoreWindow.OnClientClose = @"
//            function(sender, args)
//            {
//				var chainStore = args.get_argument();
//				if (chainStore) {
//					$get('" + ChainStoreIdTextBox.ClientID + @"').value = chainStore.Id;
//				}
//            }
//            ";
		}

		private void ConfigureSelectParentLocationForm()
		{
//            SelectParentLocationWindow.OpenerElementID = SelectParentLocationButton.ClientID;
//            SelectParentLocationWindow.OnClientClose = @"
//            function(sender, args)
//            {
//				var parentLocation = args.get_argument();
//				if (parentLocation) {
//					$get('" + ChainStoreIdTextBox.ClientID + @"').value = parentLocation.Id;
//				}
//            }
//            ";
		}
	}
}